package com.rc.saas.tenant.service.discount;

import com.rc.saas.tenant.mapper.discount.TenantDiscountMemberStationMapper;
import com.rc.saas.tenant.model.discount.TenantDiscountMemberStation;
import com.rc.saas.tenant.model.discount.TenantDiscountMemberStationExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * @author frog
 * @date 2019/11/25
 */
@Service
public class TenantDiscountMemberStationServiceImpl implements TenantDiscountMemberStationService {

    @Autowired
    private TenantDiscountMemberStationMapper tenantDiscountMemberStationMapper;

    @Override
    public TenantDiscountMemberStationMapper getMapper() {
        return tenantDiscountMemberStationMapper;
    }

    @Override
    public List<TenantDiscountMemberStation> selectMemberStationByDiscountId(Long discountPolicyId) {
        TenantDiscountMemberStationExample example = new TenantDiscountMemberStationExample();
        example.createCriteria().andDiscountPolicyIdEqualTo(discountPolicyId);
        List<TenantDiscountMemberStation> tenantDiscountMemberStations = tenantDiscountMemberStationMapper.selectByExample(example);
        if (!CollectionUtils.isEmpty(tenantDiscountMemberStations)) {
            return tenantDiscountMemberStations;
        }
        return null;
    }

    @Override
    public void deleteByBatch(List<Long> discountMemberStationIds) {
        tenantDiscountMemberStationMapper.deleteByBatch(discountMemberStationIds);
    }
}
